package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;

public class GetPriceItemByItemName {
	
	private String itemName;
	private String priceItem;
	
	public GetPriceItemByItemName(String item)
	{
		this.itemName=item;
		
	}

	
	public String getPriceItem ()
	{
		
        SQLConnection sc=new SQLConnection();
		
		     
        	try {			
        			
        		PreparedStatement ps = sc.getConnection().prepareStatement("SELECT i.Icost FROM item i WHERE i.Iname=?   ;");	

        		ps.setString(1,itemName);
        		
        		ResultSet rs=ps.executeQuery();	
        		while (rs.next())
        		{
        			
        			priceItem=rs.getString(1);
        		}
        		ps.close();
     			rs.close();
     			sc.getConnection().close();
        		
        		} catch (SQLException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		}
        	
        		return priceItem;
        	
        }
        
       

	}
	
	
	
	

